﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MTC.Common.DTO;
using MTC.DataAccess;

namespace MTC.Business.Driver
{
    public static class Driver
    {
        public static List<Common.DTO.Driver> GetDrivers()
        {
            return DriverDataAccess.GetDrivers();
        }

        public static int AddDriver(Common.DTO.Driver driver)
        {
            if (driver == null) throw new ArgumentNullException("driver");
            if (!isValidDriver(driver))
                throw new ArgumentException("driver");

            return DriverDataAccess.AddDriver(driver);
        }

        public static bool UpdateDriver(Common.DTO.Driver driver)
        {
            if (driver == null) throw new ArgumentNullException("driver");
            if (!isValidDriver(driver))
                throw new ArgumentException("driver");

            return DriverDataAccess.UpdateDriver(driver);
        }

        public static bool DeleteDriver(int DriverId)
        {
            if (DriverId == 0) throw new ArgumentNullException("DriverId");
            return DriverDataAccess.DeleteDriver(DriverId);
        }

        public static Common.DTO.Driver GetDriver(int DriverId)
        {
            if (DriverId == 0) throw new ArgumentNullException("DriverId");
            return DriverDataAccess.GetDriver(DriverId);
        }

        private static bool isValidDriver(MTC.Common.DTO.Driver driver)
        {
            return true;
        }

        public static List<Common.DTO.DriverComment> GetDriverComments(int DriverId)
        {
            if (DriverId != 0)
                return DriverDataAccess.GetDriverComments(DriverId);
            return null;
        }

        public static bool UpdateDriverComment (int DriverCommentId, int DriverId, string Comment, DateTime CommentDate)
        {
            return DriverDataAccess.UpdateDriverComment(DriverCommentId, DriverId, Comment, CommentDate);
        }

        public static List<DriverComment> GetDriverComment(int DriverId)
        {
            if (DriverId == 0) throw new ArgumentNullException("DriverId");
            return DriverDataAccess.GetDriverComments(DriverId);
        }

        public static int AddComment(int DriverId, DateTime CommentDate, string Comment)
        {
            return DriverDataAccess.AddComments(DriverId, CommentDate, Comment);
        }

        public static bool DeleteDriverComment(int DriverCommentId)
        {
            return DriverDataAccess.DeleteComment(DriverCommentId);
        }
    }
}
